package de.tum.in.protpred.optimization;

import java.io.File;

import de.tum.in.protpred.classification.TMHClassifier;
import de.tum.in.protpred.eval.TMHEvaluater;

public class GridSearchRunner
{
	
	public static void main(String[] args) throws Exception
	{
		double c = Double.valueOf(args[0]);
		double g = Double.valueOf(args[1]);
		String outFolder = args[2];
		String inFolder = args[3];
		
		c = Math.pow(2.0, c);
		g = Math.pow(2.0, g);
		
		File o = new File(outFolder);
		o.mkdir();
		
		String set1 = inFolder+"/features_manual_0.arff";
		String set2 = inFolder+"/features_manual_1.arff";
		String set3 = inFolder+"/features_manual_2.arff";
		
		String[] options = {"-G "+ g, "-C " + c,  "-S 0", "-K 2", "-D 3",  "-R 0.0", "-N 0.5", "-M 40.0", "-E 0.001", "-P 0.1"};	//"-G 0.0", "-C 1.0"	
		
		System.out.println("First combination");
		doIt(set1, set2, options, outFolder,1);
		System.out.println("Second combination");
		doIt(set2, set3, options, outFolder,2 );
		System.out.println("Third combination");
		doIt(set3, set1, options, outFolder,3 );
		
	}
	
	static void doIt(String trainingSet, String testSet, String[] options, String outFolder, int index) throws Exception
	{
		TMHClassifier classifier = new TMHClassifier(trainingSet, testSet, options );
		classifier.buildClassifier(trainingSet);
		classifier.evaluateModel(outFolder+"/"+index+"_evaluateModel");
		classifier.saveModel(outFolder+"/"+index+"_model.svm");
		TMHEvaluater.calcPerResidueScores(classifier.getConfusionMatrix(), classifier.getEvaulation() ,outFolder+"/"+index+"_scores");
	}
	

}
